package com.apes.fico.finance.model.costcollect;

import com.apes.framework.jpa.ApesBean;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.product.model.ServeType;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = OperatingCostsItem.CONST_TABLE_NAME)
public class OperatingCostsItem implements ApesBean {
    public final static String CONST_TABLE_NAME = "gl_operating_costs_item";
    @Id
    @Column(name = "id", nullable = false, length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "门店经营成本明细", padding = 8)
    @Comment("编号")
    private String id;

    @NotNull
    @ManyToOne(optional = false)
    @JoinColumn(name = "operating_costs_id", referencedColumnName = "id")
    @Comment("经营成本单号")
    private OperatingCosts operatingCosts;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "cost_type", referencedColumnName = "id")
    @Comment("成本类型")
    private Enumeration costType;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "type_cost", referencedColumnName = "id")
    @Comment("成本类别")
    private TypeCost typeCost;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "serve_type_id", referencedColumnName = "id",nullable = false)
    @Comment("服务类型")
    private ServeType serveType;

    @Column(name = "accrual_date")
    @Comment("计提时间")
    private Date accrualDate;

    @Column(name = "accrual_amt", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("计提金额")
    private double accrualAmt = 0;

    @Column(name = "real_date")
    @Comment("实际发生时间")
    private Date realDate;

    @Column(name = "real_amt", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("实际发生金额")
    private double realAmt = 0;

    @Column(name = "blunt_provision_date")
    @Comment("冲计提时间")
    private Date bluntProvisionDate;

    @Column(name = "blunt_provision_amt", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("冲计提金额")
    private double bluntProvisionAmt = 0;

    @Column(name = "blunt_actually_date")
    @Comment("冲实际发生时间")
    private Date bluntActuallyDate;

    @Column(name = "blunt_actually_amt", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("冲实际发生金额")
    private double bluntActuallyAmt = 0;
}
